import { STATUS } from "../games/aviator";

export enum Code {
    OK,
    ERROR_PARAM,                //无效的参数
    ERROR_TOKEN,                //错误的token
    INVALID_TOKEN,              //无效的token
    ERROR_REPEAT,               //重复操作
    NOT_ENOUGH_COIN = 10,        //金币不够
    ALREADY_IN_GAME = 11,       //已经在游戏中
    USER_DISABLE,              //玩家已被禁用
    ERROR_STATUS,
    MAX_TIMES,
    INVALID_BET,
    BET_NOT_FOUND,
    CASH_OUT_FAIL,
    ERROR_ENTER_GAME,
    USER_NOT_ONLINE,
    USER_LOADING,
    USER_UNLOADING
}

// 玩家状态
export enum UserStatus {
    ENABLE = 0,                 //启用
    DISABLE                     //禁用
}

// 在线状态
export enum OnlineStatus {
    OFFLINE = 0,               //离线
    ONLINE                     //在线
}

// 扫雷倍率规则
export class MinesRole {

    /** 获取倍率
     * @mines 雷数
     * @dNum  钻石数
     */
    public static get_role(mines: number, dNum: number): number {

        let role = [
            //1 mines
            [1, 1, 1.01], [1, 2, 1.08], [1, 3, 1.12], [1, 4, 1.18], [1, 5, 1.24],
            [1, 6, 1.30], [1, 7, 1.37], [1, 8, 1.46], [1, 9, 1.55], [1, 10, 1.65],
            [1, 11, 1.77], [1, 12, 1.90], [1, 13, 2.06], [1, 14, 2.25], [1, 15, 2.47],
            [1, 16, 2.75], [1, 17, 3.09], [1, 18, 3.54], [1, 19, 4.12], [1, 20, 4.95],
            [1, 21, 6.19], [1, 22, 8.25], [1, 23, 12.38], [1, 24, 24.75],

            //2 mines
            [2, 1, 1.08], [2, 2, 1.17], [2, 3, 1.29], [2, 4, 1.41], [2, 5, 1.56],
            [2, 6, 1.74], [2, 7, 1.94], [2, 8, 2.18], [2, 9, 2.47], [2, 10, 2.83],
            [2, 11, 3.26], [2, 12, 3.81], [2, 13, 4.50], [2, 14, 5.40], [2, 15, 6.60],
            [2, 16, 8.25], [2, 17, 10.61], [2, 18, 14.14], [2, 19, 19.80], [2, 20, 29.70],
            [2, 21, 49.50], [2, 22, 99], [2, 23, 297],

            //3 mines
            [3, 1, 1.12], [3, 2, 1.29], [3, 3, 1.48], [3, 4, 1.71], [3, 5, 2.00],
            [3, 6, 2.35], [3, 7, 2.79], [3, 8, 3.35], [3, 9, 4.07], [3, 10, 5.00],
            [3, 11, 6.26], [3, 12, 7.96], [3, 13, 10.35], [3, 14, 13.8], [3, 15, 18.97],
            [3, 16, 27.11], [3, 17, 40.66], [3, 18, 65.06], [3, 19, 113.85], [3, 20, 227.7],
            [3, 21, 569.25], [3, 22, 2277],

            //4 mines
            [4, 1, 1.18], [4, 2, 1.41], [4, 3, 1.71], [4, 4, 2.09], [4, 5, 2.58],
            [4, 6, 3.23], [4, 7, 4.09], [4, 8, 5.26], [4, 9, 6.88], [4, 10, 9.17],
            [4, 11, 12.51], [4, 12, 17.52], [4, 13, 25.3], [4, 14, 37.95], [4, 15, 59.64],
            [4, 16, 99.39], [4, 17, 178.91], [4, 18, 357.81], [4, 19, 834.9], [4, 20, 2504],
            [4, 21, 12523],

            //5 mines
            [5, 1, 1.24], [5, 2, 1.56], [5, 3, 2], [5, 4, 2.58], [5, 5, 3.39],
            [5, 6, 4.52], [5, 7, 6.14], [5, 8, 8.5], [5, 9, 12.04], [5, 10, 17.52],
            [5, 11, 26.27], [5, 12, 40.87], [5, 13, 66.41], [5, 14, 113.85], [5, 15, 208.72],
            [5, 16, 417.45], [5, 17, 939.26], [5, 18, 2504], [5, 19, 8766], [5, 20, 52598],

            //6 mines
            [6, 1, 1.3], [6, 2, 1.74], [6, 3, 2.35], [6, 4, 3.23], [6, 5, 4.52],
            [6, 6, 6.46], [6, 7, 9.44], [6, 8, 14.17], [6, 9, 21.89], [6, 10, 35.03],
            [6, 11, 53.33], [6, 12, 102.17], [6, 13, 189.75], [6, 14, 379.5], [6, 15, 834.9],
            [6, 16, 2087], [6, 17, 6261], [6, 18, 25047], [6, 19, 175329],

            //7 mines
            [7, 1, 1.37], [7, 2, 1.94], [7, 3, 2.79], [7, 4, 4.09], [7, 5, 6.14],
            [7, 6, 9.44], [7, 7, 14.95], [7, 8, 24.47], [7, 9, 41.6], [7, 10, 73.95],
            [7, 11, 138.66], [7, 12, 277.33], [7, 13, 606.87], [7, 14, 1442], [7, 15, 3956],
            [7, 16, 13219], [7, 17, 59486], [7, 18, 475893],

            //8 mines
            [8, 1, 1.46], [8, 2, 2.18], [8, 3, 3.35], [8, 4, 5.26], [8, 5, 8.05],
            [8, 6, 14.17], [8, 7, 24.47], [8, 8, 44.05], [8, 9, 83.2], [8, 10, 166.4],
            [8, 11, 356.56], [8, 12, 831.98], [8, 13, 2163], [8, 14, 6489], [8, 15, 23794],
            [8, 16, 118973], [8, 17, 1070759],

            //9 mines
            [9, 1, 1.55], [9, 2, 2.47], [9, 3, 4.07], [9, 4, 6.88], [9, 5, 12.04],
            [9, 6, 21.89], [9, 7, 41.6], [9, 8, 83.2], [9, 9, 176.8], [9, 10, 404.1],
            [9, 11, 1010], [9, 12, 2828], [9, 13, 9193], [9, 14, 36773], [9, 15, 202254],
            [9, 16, 2022545],

            //10 mines
            [10, 1, 1.65], [10, 2, 2.83], [10, 3, 5], [10, 4, 9.17], [10, 5, 17.52],
            [10, 6, 35.03], [10, 7, 73.95], [10, 8, 166.4], [10, 9, 404.1], [10, 10, 1077],
            [10, 11, 3232], [10, 12, 11314], [10, 13, 19031], [10, 14, 294188], [10, 15, 3236072],

            //11 mines
            [11, 1, 1.77], [11, 2, 3.26], [11, 3, 6.26], [11, 4, 12.51], [11, 5, 26.77],
            [11, 6, 58.38], [11, 7, 136.66], [11, 8, 356.56], [11, 9, 1010], [11, 10, 3232],
            [11, 11, 12123], [11, 12, 56574], [11, 13, 367735], [11, 14, 4412826],

            //12 mines
            [12, 1, 1.9], [12, 2, 3.81], [12, 3, 7.96], [12, 4, 17.52], [12, 5, 40.87],
            [12, 6, 102.17], [12, 7, 277.33], [12, 8, 831.98], [12, 9, 2828], [12, 10, 11314],
            [12, 11, 56574], [12, 12, 396022], [12, 13, 5148297],

            //13 mines
            [13, 1, 2.06], [13, 2, 4.5], [13, 3, 10.35], [13, 4, 25.3], [13, 5, 66.41],
            [13, 6, 189.75], [13, 7, 600.87], [13, 8, 2163], [13, 9, 9193], [13, 10, 49031],
            [13, 11, 367735], [13, 12, 5148297],

            //14 mines
            [14, 1, 2.25], [14, 2, 5.4], [14, 3, 13.8], [14, 4, 37.95], [14, 5, 113.85],
            [14, 6, 379.5], [14, 7, 1442], [14, 8, 6489], [14, 9, 36773], [14, 10, 294188],
            [14, 11, 4412826],

            //15 mines
            [15, 1, 2.47], [15, 2, 6.6], [15, 3, 18.97], [15, 4, 59.64], [15, 5, 208.72],
            [15, 6, 834.9], [15, 7, 3965], [15, 8, 23794], [15, 9, 202254], [15, 10, 3236072],

            //16 mines
            [16, 1, 2.75], [16, 2, 8.25], [16, 3, 27.11], [16, 4, 99.39], [16, 5, 417.45],
            [16, 6, 2087], [16, 7, 13219], [16, 8, 118973], [16, 9, 2022545],

            //17 mines
            [17, 1, 3.09], [17, 2, 10.61], [17, 3, 40.66], [17, 4, 178.91], [17, 5, 939.26],
            [17, 6, 6261], [17, 7, 59486], [17, 8, 1070759],

            //18 mines
            [18, 1, 3.54], [18, 2, 14.14], [18, 3, 65.06], [18, 4, 357.81], [18, 5, 2504],
            [18, 6, 25047], [18, 7, 475893],

            //19 mines
            [19, 1, 4.12], [19, 2, 19.8], [19, 3, 113.85], [19, 4, 834.9], [19, 5, 8766],
            [19, 6, 175329],

            //20 mines
            [20, 1, 4.95], [20, 2, 29.7], [20, 3, 227.7], [20, 4, 2504], [20, 5, 52598],

            //21 mines
            [21, 1, 6.19], [21, 2, 49.5], [21, 3, 569.25], [21, 4, 12523],

            //22 mines
            [22, 1, 8.25], [22, 2, 99], [22, 3, 2277],

            //23 mines
            [23, 1, 12.37], [23, 2, 297],

            //24 mines
            [24, 1, 24.7]


        ]
        for (const values of role) {
            if (values[0] == mines && values[1] == dNum) {
                return values[2]
            }
        }
        return 0
    }


    /** 统计数组中指定元素个数
     * @arr 数组
     * @res  值
     */
    public static countNum(arr: Array<number>, res: number) {
        let num = 0
        for (let i = 0; i < arr.length; i++) {
            if (res === arr[i]) {
                num++
            }
        }
        return num;
    }

}
